import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'
import BusinessList from '../views/BusinessList.vue'
import BusinessInfo from '../views/BusinessInfo.vue'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
import Order from '../views/Order.vue'
import Useraddress from '../views/UserAddress.vue'
import AddUseraddress from '../views/AddUserAddress.vue'
import EditUseraddress from '../views/EditUserAddress.vue'
import Payment from '../views/Payment.vue'
import OrderLIst from '../views/OrderList.vue'
import Find from '../views/Find.vue'
Vue.use(VueRouter)

  const routes = [
    {
      path:'/',
      name:'Home',
      component:Index
    },
    {
      path:'/index',
      name:'Index',
      component:Index
    },{
      path:'/businessList',
      name:'BusinessList',
      component:BusinessList
    },
    {
      path:'/businessInfo',
      name:'BusinessInfo',
      component:BusinessInfo
    },
    {
      path:'/login',
      name:'Login',
      component:Login
    },
    {
      path:'/register',
      name:'Register',
      component:Register
    },
    {
      path:'/orders',
      name:'Orders',
      component:Order
    },
    {
      path:'/useraddress',
      name:'Useraddress',
      component:Useraddress
    },
    {
      path:'/adduseraddress',
      name:'AddUseraddress',
      component:AddUseraddress
    },
    {
      path:'/edituseraddress',
      name:'EditUseraddress',
      component:EditUseraddress
    },
    {
      path:'/payment',
      name:'Payment',
      component:Payment
    },
    {
      path:'/orderList',
      name:'OrderList',
      component:OrderLIst
    },
    {
      path:'/find',
      name:'Find',
      component:Find
    },
  ]

//解决重复路由报异常的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(error=> error)
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
